博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
微信接口开发之高级篇系列【用户分组接口和生成带参数的二维码】
阅读量:6818 次
发布时间:2019-06-26

本文共 1758 字,大约阅读时间需要 5 分钟。

appid = C('WECHAT_OAUTH2.APPID'); $this->appSecret = C('WECHAT_OAUTH2.APPSECRET'); // 缓存起来 if (!session('token')) { $this->WechatAuth = new WechatAuth($this->appid, $this->appSecret);//初始化WechatAuth类 $WechatAuth = $this->WechatAuth; $token = $WechatAuth->getAccessToken(); session(array('expire' => $token['expires_in']));//设置过期时间 session('token', $token['accsess_token']);//缓存token $this->accsess_token = $token; } else { $token = session('token'); $this->WechatAuth = new WechatAuth($this->appid, $this->appSecret, $token);//初始化WechatAuth类 $this->accsess_token = $token;//缓存token } } public function test() { echo 'selectGroupsGet'; } //获取所有用户组 public function selectGroupsGet() { header('Content-type:text/html;charset=utf-8;'); $WechatAuth = $this->WechatAuth; $data = $WechatAuth->groupsGet(); var_dump($data); } //创建一个分组 public function createGroup() { header('Content-type:text/html;charset=utf-8;'); $WechatAuth = $this->WechatAuth; $data = $WechatAuth->groupsCreate('万少波分组'); var_dump($data); } //查询一下指定用户的分组 public function GroupId() { $m = M('users'); $user = $m->find(3); $openid = $user['openid']; $WechatAuth = $this->WechatAuth; $data = $WechatAuth->groupsGetid($openid); var_dump($data); }}

 带参数的二维码:

// 生成带参数的二维码    public function createCode()    {        $WechatAuth = $this->WechatAuth;        $ticket = $WechatAuth->qrcodeCreate("10086"); //返回临时票据ticket        $src = $WechatAuth->showqrcode($ticket['ticket']); //根据ticket获取二维码URL        echo "";    }

 

转载地址:http://ngszl.baihongyu.com/

你可能感兴趣的文章